import { FETCH_JOKE, RECEIVED_JOKE } from '@/pages/joke/constants';

const reducer = (state = { data: '' }, action: { type: string; data: string; }) => {
  switch (action.type) {
    case FETCH_JOKE:
      return { ...state, data: '', loading: true };
    case RECEIVED_JOKE:
      return { ...state, data: action.data, loading: false };
    default:
      return state;
  }
};

export default reducer;
